<?php

namespace Frieza\Modules\Position\Controllers;

use Encore\Admin\Grid;
use Encore\Admin\Widgets\Form;


class HomeFollowCardController extends BaseController
{
    use BaseTrait;

    public function beforeLinkForm(Form $form)
    {
        $form->number('base.pos', '展示位置')->max(20);
        $form->imgUpload('base.pic_id', 'banner图');
    }

    public function extendList(Grid $grid)
    {
        $grid->column('pos', '展示位置')->display(function ($title, Grid\Column $column) {
            $pos = $this->pos % 4;
            $map = ['primary','warning','success','info','danger'];
            return $column->label($map[$pos]);
        });
        $grid->column('pic_url', '图片')->image();
    }
}
